package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3080 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3080.class.getResource("P3080.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		int n = Integer.valueOf(line.trim());
		for (int i = 0; i < n; i ++) {
			line = stdin.readLine();
			int m = Integer.valueOf(line.trim());
			String[] strs = new String[m];
			for (int j = 0; j < m; j ++) {
				strs[j] = stdin.readLine().trim();
			}
			String s = common(strs);
			if (s == null) {
				System.out.println("no significant commonalities");
			} else {
				System.out.println(s);
			}
		}
	}

	private static String common(String[] strs) {
		
		List<String> common = new ArrayList<String>();
		for (int l = 60; l > 2; l --) {
			if (common.size() > 0 && common.get(0).length() > l) {
				break;
			}
			for (int i = 0; i < 61-l; i ++) {
				String s = strs[0].substring(i, l+i);
				boolean all = true;
				for (int j = 1; j < strs.length; j ++) {
					if (strs[j].indexOf(s) < 0) {
						all = false;
						break;
					}
				}
				if (all) {
					common.add(s);
				}
			}
		}
		Collections.sort(common);
		if (common.size() > 0) {
			return common.get(0);
		} else {
			return null;
		}
	}
}